package com.hoki.zj.Listener;

import com.hoki.zj.batch.domain.BlogInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.ItemReadListener;

import static java.lang.String.format;

public class MyReaderListener implements ItemReadListener<BlogInfo> {

    private Logger logger = LoggerFactory.getLogger(MyReaderListener.class);

    /**
     * 1.読み込み前
     */
    @Override
    public void beforeRead() {

    }

    /**
     * 2.読み込み後
     */
    @Override
    public void afterRead(BlogInfo item) {

    }

    /**
     * 3.読み込みエラー
     */
    @Override
    public void onReadError(Exception ex) {
        try {
            logger.info(format("%s%n", ex.getMessage()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
